package com.sina.weibo;

import android.app.AlertDialog;
import android.app.AlertDialog.Builder;
import android.content.BroadcastReceiver;
import android.content.Intent;
import android.content.IntentFilter;
import android.content.res.Resources;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.drawable.BitmapDrawable;
import android.os.AsyncTask;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.TextUtils;
import android.view.KeyEvent;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;
import com.sina.weibo.models.User;
import com.sina.weibo.models.UserInfo;
import java.io.File;

public class MyInfoActivity extends BaseActivity
  implements View.OnClickListener
{
  private final int RELOAD_USERINFO = 0;
  Handler handler;
  private boolean isReload;
  private Button mBtnEditOrAttend;
  private String mCacheDir;
  private ImageView mIvGental;
  private ImageView mIvPortrait;
  private RelativeLayout mLlAttend;
  private LinearLayout mLlFans;
  private LinearLayout mLlTopic;
  private LoadUserInfoTask mLoadUserInfoTask;
  private String mNick;
  private CustomToast mPgToast;
  private RelativeLayout mRlFav;
  private LinearLayout mRlWeibo;
  private BroadcastReceiver mSwitchModeReceiver;
  private TextView mTvAccount;
  private TextView mTvAddress;
  private TextView mTvAttend_Count;
  private TextView mTvFans_Count;
  private TextView mTvFav_Count;
  private TextView mTvNickName;
  private TextView mTvTopic_Count;
  private TextView mTvWeibo_Count;
  private String mUid;
  private User mUser;
  private UserInfo mUserInfo;
  private boolean mUserTaskFree = true;
  private boolean misVip = true;

  public MyInfoActivity()
  {
    MyInfoActivity.1 local1 = new MyInfoActivity.1(this);
    this.handler = local1;
    this.isReload = false;
    MyInfoActivity.2 local2 = new MyInfoActivity.2(this);
    this.mSwitchModeReceiver = local2;
  }

  private void fansOnClickAction()
  {
    Intent localIntent1 = new Intent(this, UserWeiboAttentionFansList.class);
    String str1 = this.mUid;
    Intent localIntent2 = localIntent1.putExtra("uid", str1);
    Intent localIntent3 = localIntent1.putExtra("mode", 3);
    String str2 = StaticInfo.mUsername;
    Intent localIntent4 = localIntent1.putExtra("username", str2);
    String str3 = StaticInfo.mPassword;
    Intent localIntent5 = localIntent1.putExtra("password", str3);
    if (this.mNick != null)
    {
      String str4 = this.mNick;
      Intent localIntent6 = localIntent1.putExtra("nick", str4);
    }
    startActivity(localIntent1);
  }

  private void favOnClickAction()
  {
    Intent localIntent = new Intent(this, FavoriteActivity.class);
    startActivity(localIntent);
  }

  private void focusOnClickAction()
  {
    Intent localIntent1 = new Intent(this, UserWeiboAttentionFansList.class);
    String str1 = this.mUid;
    Intent localIntent2 = localIntent1.putExtra("uid", str1);
    Intent localIntent3 = localIntent1.putExtra("mode", 2);
    String str2 = StaticInfo.mUsername;
    Intent localIntent4 = localIntent1.putExtra("username", str2);
    String str3 = StaticInfo.mPassword;
    Intent localIntent5 = localIntent1.putExtra("password", str3);
    if (this.mNick != null)
    {
      String str4 = this.mNick;
      Intent localIntent6 = localIntent1.putExtra("nick", str4);
    }
    startActivity(localIntent1);
  }

  private void loadUserInfo()
  {
    if (this.mUserTaskFree)
    {
      LoadUserInfoTask localLoadUserInfoTask1 = new LoadUserInfoTask(null);
      this.mLoadUserInfoTask = localLoadUserInfoTask1;
      LoadUserInfoTask localLoadUserInfoTask2 = this.mLoadUserInfoTask;
      Void[] arrayOfVoid = new Void[0];
      AsyncTask localAsyncTask = localLoadUserInfoTask2.execute(arrayOfVoid);
    }
  }

  private void registBroadcastListener()
  {
    IntentFilter localIntentFilter = new IntentFilter();
    localIntentFilter.addAction("com.sina.weibo.action.SWITCHUSER");
    BroadcastReceiver localBroadcastReceiver = this.mSwitchModeReceiver;
    Intent localIntent = registerReceiver(localBroadcastReceiver, localIntentFilter);
  }

  private void reloadUserInfo()
  {
    if (StaticInfo.mUser.nick == null)
    {
      str = this.mNick;
      this.mNick = str;
      if (StaticInfo.mUser.uid != null)
        break label71;
    }
    label71: for (String str = this.mUid; ; str = StaticInfo.mUser.uid)
    {
      this.mUid = str;
      Message localMessage = new Message();
      localMessage.what = 0;
      boolean bool = this.handler.sendMessage(localMessage);
      return;
      str = StaticInfo.mUser.nick;
      break;
    }
  }

  private void setupGroupCount(UserInfo paramUserInfo)
  {
    TextView localTextView1 = this.mTvAttend_Count;
    String str1 = String.valueOf(paramUserInfo.meattnum);
    localTextView1.setText(str1);
    TextView localTextView2 = this.mTvFans_Count;
    String str2 = String.valueOf(paramUserInfo.attmenum);
    localTextView2.setText(str2);
    TextView localTextView3 = this.mTvFav_Count;
    String str3 = String.valueOf(paramUserInfo.favBlogNum);
    localTextView3.setText(str3);
    TextView localTextView4 = this.mTvWeibo_Count;
    String str4 = String.valueOf(paramUserInfo.mblognum);
    localTextView4.setText(str4);
    TextView localTextView5 = this.mTvTopic_Count;
    String str5 = String.valueOf(paramUserInfo.favHotwordNum);
    localTextView5.setText(str5);
  }

  private void setupUI(UserInfo paramUserInfo)
  {
    this.mIvPortrait.setVisibility(0);
    this.mIvPortrait.setImageResource(2130838011);
    String str3;
    ImageView localImageView;
    if (!TextUtils.isEmpty(paramUserInfo.portrait))
    {
      String str1 = this.mCacheDir;
      String str2 = paramUserInfo.portrait;
      str3 = Utils.checkCache(str1, str2);
      if (str3 == null)
      {
        LoadPortraitTask localLoadPortraitTask = new LoadPortraitTask(null);
        String[] arrayOfString = new String[2];
        String str4 = paramUserInfo.portrait;
        arrayOfString[0] = str4;
        String str5 = getCacheDir().getAbsolutePath();
        arrayOfString[1] = str5;
        AsyncTask localAsyncTask = localLoadPortraitTask.execute(arrayOfString);
      }
    }
    else
    {
      TextView localTextView1 = this.mTvNickName;
      String str6 = paramUserInfo.nick;
      localTextView1.setText(str6);
      TextView localTextView2 = this.mTvAccount;
      String str7 = StaticInfo.mUsername;
      localTextView2.setText(str7);
      TextView localTextView3 = this.mTvAddress;
      String str8 = paramUserInfo.province;
      localTextView3.setText(str8);
      this.mBtnEditOrAttend.setVisibility(4);
      localImageView = this.mIvGental;
      if (paramUserInfo.gender != 1)
        break label262;
    }
    label262: int j;
    for (int i = 2130837950; ; j = 2130837952)
    {
      localImageView.setImageResource(i);
      setupGroupCount(paramUserInfo);
      return;
      Bitmap localBitmap2 = BitmapFactory.decodeFile(str3);
      if (localBitmap2 == null)
        break;
      localImageView = this.mIvPortrait;
      Bitmap localBitmap1 = Utils.outputRoundRectBitmap(localBitmap2);
      if (paramUserInfo.vip);
      int m;
      for (int k = 1; ; m = 0)
      {
        Bitmap localBitmap3 = Utils.outputBmp(this, localBitmap1, k);
        localImageView.setImageBitmap(localBitmap3);
        break;
      }
    }
  }

  private void showProgress(int paramInt)
  {
    if (this.mPgToast == null)
    {
      CustomToast localCustomToast = Utils.createProgressCustomToast(paramInt, this);
      this.mPgToast = localCustomToast;
    }
    this.mPgToast.show();
  }

  private void topicOnClickAction()
  {
    Intent localIntent1 = new Intent(this, UserWeiboAttentionFansList.class);
    String str1 = this.mUid;
    Intent localIntent2 = localIntent1.putExtra("uid", str1);
    Intent localIntent3 = localIntent1.putExtra("mode", 4);
    String str2 = StaticInfo.mUsername;
    Intent localIntent4 = localIntent1.putExtra("username", str2);
    String str3 = StaticInfo.mPassword;
    Intent localIntent5 = localIntent1.putExtra("password", str3);
    if (this.mNick != null)
    {
      String str4 = this.mNick;
      Intent localIntent6 = localIntent1.putExtra("nick", str4);
    }
    startActivity(localIntent1);
  }

  private void weiboOnClickAction()
  {
    Intent localIntent1 = new Intent(this, UserWeiboAttentionFansList.class);
    String str1 = this.mUid;
    Intent localIntent2 = localIntent1.putExtra("uid", str1);
    Intent localIntent3 = localIntent1.putExtra("mode", 1);
    String str2 = StaticInfo.mUsername;
    Intent localIntent4 = localIntent1.putExtra("username", str2);
    String str3 = StaticInfo.mPassword;
    Intent localIntent5 = localIntent1.putExtra("password", str3);
    if (this.mNick != null)
    {
      String str4 = this.mNick;
      Intent localIntent6 = localIntent1.putExtra("nick", str4);
    }
    startActivity(localIntent1);
  }

  protected void handleTitleBarEvent(int paramInt)
  {
    switch (paramInt)
    {
    default:
    case 0:
    case 1:
    }
    while (true)
    {
      return;
      if (StaticInfo.mUser.nick == null)
      {
        str = this.mNick;
        label39: this.mNick = str;
        if (StaticInfo.mUser.uid != null)
          break label112;
      }
      label112: for (String str = this.mUid; ; str = StaticInfo.mUser.uid)
      {
        this.mUid = str;
        LoadUserInfoTask localLoadUserInfoTask1 = new LoadUserInfoTask(null);
        this.mLoadUserInfoTask = localLoadUserInfoTask1;
        LoadUserInfoTask localLoadUserInfoTask2 = this.mLoadUserInfoTask;
        Void[] arrayOfVoid = new Void[0];
        AsyncTask localAsyncTask = localLoadUserInfoTask2.execute(arrayOfVoid);
        break;
        str = StaticInfo.mUser.nick;
        break label39;
      }
      Intent localIntent = Utils.editNewBlog(this);
      MainTabActivity localMainTabActivity = (MainTabActivity)getParent();
      if (localMainTabActivity != null)
      {
        localMainTabActivity.startActivity(localIntent);
        continue;
      }
      startActivity(localIntent);
    }
  }

  public void onClick(View paramView)
  {
    RelativeLayout localRelativeLayout1 = this.mRlFav;
    if (paramView == localRelativeLayout1)
      favOnClickAction();
    while (true)
    {
      return;
      LinearLayout localLinearLayout1 = this.mRlWeibo;
      if (paramView == localLinearLayout1)
      {
        weiboOnClickAction();
        continue;
      }
      RelativeLayout localRelativeLayout2 = this.mLlAttend;
      if (paramView == localRelativeLayout2)
      {
        focusOnClickAction();
        continue;
      }
      LinearLayout localLinearLayout2 = this.mLlFans;
      if (paramView == localLinearLayout2)
      {
        fansOnClickAction();
        continue;
      }
      LinearLayout localLinearLayout3 = this.mLlTopic;
      if (paramView == localLinearLayout3)
      {
        topicOnClickAction();
        continue;
      }
      super.onClick(paramView);
    }
  }

  public void onCreate(Bundle paramBundle)
  {
    super.onCreate(paramBundle);
    setView(R.layout.myinfo);
    String str1 = getString(R.string.menu_contact);
    String str2 = getString(R.string.main_edit);
    String str3 = getString(R.string.main_reload);
    setTitleBar(1, str2, str1, str3);
    this.isReload = false;
    String str4 = getCacheDir().getAbsolutePath();
    this.mCacheDir = str4;
    Intent localIntent = getIntent();
    User localUser = StaticInfo.mUser;
    this.mUser = localUser;
    String str5 = localIntent.getStringExtra("nick");
    this.mNick = str5;
    String str6 = localIntent.getStringExtra("uid");
    this.mUid = str6;
    if (((this.mNick == null) || (this.mNick.length() == 0)) && ((this.mUid == null) || (this.mUid.length() == 0)) && (StaticInfo.mUser != null))
    {
      String str7 = StaticInfo.mUser.nick;
      this.mNick = str7;
      String str8 = StaticInfo.mUser.uid;
      this.mUid = str8;
    }
    LinearLayout localLinearLayout1 = (LinearLayout)findViewById(2131624064);
    this.mRlWeibo = localLinearLayout1;
    this.mRlWeibo.setOnClickListener(this);
    LinearLayout localLinearLayout2 = (LinearLayout)findViewById(2131624070);
    this.mLlTopic = localLinearLayout2;
    this.mLlTopic.setOnClickListener(this);
    LinearLayout localLinearLayout3 = (LinearLayout)findViewById(2131624067);
    this.mLlFans = localLinearLayout3;
    this.mLlFans.setOnClickListener(this);
    RelativeLayout localRelativeLayout1 = (RelativeLayout)findViewById(2131624061);
    this.mLlAttend = localRelativeLayout1;
    this.mLlAttend.setOnClickListener(this);
    RelativeLayout localRelativeLayout2 = (RelativeLayout)findViewById(2131624072);
    this.mRlFav = localRelativeLayout2;
    this.mRlFav.setOnClickListener(this);
    ImageView localImageView1 = (ImageView)findViewById(2131624049);
    this.mIvPortrait = localImageView1;
    if (((BitmapDrawable)getResources().getDrawable(2130838011)).getBitmap().isRecycled())
      Bitmap localBitmap1 = BitmapFactory.decodeResource(getResources(), 2130838011);
    ImageView localImageView2 = this.mIvPortrait;
    Bitmap localBitmap2 = Utils.outputRoundRectBitmap(BitmapFactory.decodeResource(getResources(), 2130838011));
    Bitmap localBitmap3 = Utils.outputBmp(this, localBitmap2, 0);
    localImageView2.setImageBitmap(localBitmap3);
    TextView localTextView1 = (TextView)findViewById(2131624050);
    this.mTvNickName = localTextView1;
    ImageView localImageView3 = (ImageView)findViewById(2131624051);
    this.mIvGental = localImageView3;
    Button localButton = (Button)findViewById(2131624052);
    this.mBtnEditOrAttend = localButton;
    this.mBtnEditOrAttend.setOnClickListener(this);
    TextView localTextView2 = (TextView)findViewById(2131624055);
    this.mTvAddress = localTextView2;
    TextView localTextView3 = (TextView)findViewById(2131624058);
    this.mTvAccount = localTextView3;
    TextView localTextView4 = (TextView)findViewById(2131624065);
    this.mTvWeibo_Count = localTextView4;
    TextView localTextView5 = (TextView)findViewById(2131624068);
    this.mTvFans_Count = localTextView5;
    TextView localTextView6 = (TextView)findViewById(2131624071);
    this.mTvTopic_Count = localTextView6;
    TextView localTextView7 = (TextView)findViewById(2131624062);
    this.mTvAttend_Count = localTextView7;
    TextView localTextView8 = (TextView)findViewById(2131624073);
    this.mTvFav_Count = localTextView8;
    loadUserInfo();
    registBroadcastListener();
  }

  protected void onDestroy()
  {
    if ((!this.mUserTaskFree) && (this.mLoadUserInfoTask != null) && (!this.mLoadUserInfoTask.isCancelled()))
    {
      if ((!this.mUserTaskFree) && (this.mPgToast != null))
        this.mPgToast.cancel();
      boolean bool = this.mLoadUserInfoTask.cancel(1);
      this.mUserTaskFree = 1;
    }
    BroadcastReceiver localBroadcastReceiver = this.mSwitchModeReceiver;
    unregisterReceiver(localBroadcastReceiver);
    super.onDestroy();
  }

  public boolean onKeyDown(int paramInt, KeyEvent paramKeyEvent)
  {
    if ((paramInt == 4) && (getParent() != null))
    {
      AlertDialog.Builder localBuilder1 = new AlertDialog.Builder(this);
      AlertDialog.Builder localBuilder2 = localBuilder1.setTitle(2131427444).setIcon(2130837926).setCancelable(0);
      MyInfoActivity.3 local3 = new MyInfoActivity.3(this);
      AlertDialog.Builder localBuilder3 = localBuilder2.setPositiveButton(2131427441, local3);
      MyInfoActivity.4 local4 = new MyInfoActivity.4(this);
      AlertDialog.Builder localBuilder4 = localBuilder3.setNegativeButton(2131427436, local4);
      AlertDialog localAlertDialog = localBuilder1.show();
    }
    boolean bool;
    for (int i = 1; ; bool = super.onKeyDown(paramInt, paramKeyEvent))
      return i;
  }

  protected void onPause()
  {
    super.onPause();
    if (this.mPgToast != null)
      this.mPgToast.cancel();
  }

  protected void onResume()
  {
    super.onResume();
    if ((!TextUtils.isEmpty(this.mUid)) && (StaticInfo.mUser != null) && (!TextUtils.isEmpty(StaticInfo.mUser.uid)))
    {
      String str1 = this.mUid;
      String str2 = StaticInfo.mUser.uid;
      if (!str1.equalsIgnoreCase(str2));
    }
    else if (!this.isReload)
    {
      return;
    }
    String str3 = this.mUid;
    String str4 = StaticInfo.mUser.uid;
    if (str3.equalsIgnoreCase(str4))
    {
      reloadUserInfo();
      this.isReload = 0;
    }
  }

  class LoadPortraitTask extends AsyncTask<String, String, String>
  {
    private LoadPortraitTask()
    {
    }

    protected String doInBackground(String[] paramArrayOfString)
    {
      String str1 = paramArrayOfString[0];
      String str2 = paramArrayOfString[1];
      Object localObject1 = null;
      try
      {
        String str3 = RPCHelper.getInstance(MyInfoActivity.this.getApplication()).getPicture(str1, str2);
        File localFile = new File(str3);
        if (localFile.exists())
        {
          String str4 = localFile.toString();
          localObject1 = str4;
        }
        localObject2 = localObject1;
        return localObject2;
      }
      catch (Exception localException)
      {
        while (true)
          Object localObject2 = null;
      }
    }

    protected void onPostExecute(String paramString)
    {
      ImageView localImageView;
      MyInfoActivity localMyInfoActivity;
      Bitmap localBitmap1;
      if (paramString != null)
      {
        localImageView = MyInfoActivity.this.mIvPortrait;
        localMyInfoActivity = MyInfoActivity.this;
        localBitmap1 = Utils.outputRoundRectBitmap(BitmapFactory.decodeResource(MyInfoActivity.this.getResources(), 2130838011));
        if (!MyInfoActivity.this.mUserInfo.vip)
          break label68;
      }
      label68: int j;
      for (int i = 1; ; j = 0)
      {
        Bitmap localBitmap2 = Utils.outputBmp(localMyInfoActivity, localBitmap1, i);
        localImageView.setImageBitmap(localBitmap2);
        return;
      }
    }
  }

  class LoadUserInfoTask extends AsyncTask<Void, Void, UserInfo>
  {
    private LoadUserInfoTask()
    {
    }

    protected UserInfo doInBackground(Void[] paramArrayOfVoid)
    {
      try
      {
        if (MyInfoActivity.this.mUser == null)
        {
          localUserInfo1 = null;
          return localUserInfo1;
        }
        MyInfoActivity localMyInfoActivity1;
        UserInfo localUserInfo2;
        if (MyInfoActivity.this.mUid != null)
        {
          localMyInfoActivity1 = MyInfoActivity.this;
          RPCHelper localRPCHelper1 = RPCHelper.getInstance(MyInfoActivity.this.getApplication());
          User localUser1 = MyInfoActivity.this.mUser;
          String str1 = MyInfoActivity.this.mUid;
          localUserInfo2 = localRPCHelper1.getUserInfo(localUser1, str1, null);
        }
        MyInfoActivity localMyInfoActivity2;
        UserInfo localUserInfo3;
        for (localMyInfoActivity1.mUserInfo = localUserInfo2; ; localMyInfoActivity2.mUserInfo = localUserInfo3)
        {
          localUserInfo1 = MyInfoActivity.this.mUserInfo;
          break;
          localMyInfoActivity2 = MyInfoActivity.this;
          RPCHelper localRPCHelper2 = RPCHelper.getInstance(MyInfoActivity.this.getApplication());
          User localUser2 = MyInfoActivity.this.mUser;
          String str2 = MyInfoActivity.this.mNick;
          localUserInfo3 = localRPCHelper2.getUserInfo(localUser2, null, str2);
        }
      }
      catch (RPCHelper.HttpException localHttpException)
      {
        while (true)
          UserInfo localUserInfo1 = null;
      }
    }

    protected void onCancelled()
    {
      MyInfoActivity.this.mUserTaskFree = 1;
      if (MyInfoActivity.this.mPgToast != null)
        MyInfoActivity.this.mPgToast.cancel();
    }

    protected void onPostExecute(UserInfo paramUserInfo)
    {
      MyInfoActivity.this.mUserTaskFree = 1;
      if (MyInfoActivity.this.mPgToast != null)
        MyInfoActivity.this.mPgToast.cancel();
      if (paramUserInfo == null)
      {
        MyInfoActivity localMyInfoActivity = MyInfoActivity.this;
        String str = MyInfoActivity.this.getString(2131427409);
        Toast.makeText(localMyInfoActivity, str, 0).show();
      }
      while (true)
      {
        return;
        MyInfoActivity.this.setupUI(paramUserInfo);
      }
    }

    protected void onPreExecute()
    {
      MyInfoActivity.this.mUserTaskFree = 0;
      MyInfoActivity.this.showProgress(2131427408);
    }
  }
}

/* Location:           D:\Program Files\eclipse\apktool-r01-3\新浪微博\classes.dex.dex2jar.jar
 * Qualified Name:     com.sina.weibo.MyInfoActivity
 * JD-Core Version:    0.6.0
 */